package com.google.code.sysarch.v3.pre;

import java.awt.Graphics;
import java.awt.Image;

/**
 * A sprite i a drawn image
 * @author Fabian Nicolay
 */
public class Sprite {
	private Image image;
	
	/**
	 * Creates a new sprite.
	 * For optimized memory usage and hardware acceleration sprites should be
	 * created by SpritePool.get(...) and not directly by using this method.
	 * @param image how should the sprite look like.
	 */
	public Sprite(Image image) {
		this.image = image;
	} 
	
	/**
	 * Retuns the width of the sprite
	 * @return the width of the drawn sprite
	 */
	public int getWidth() {
		return image.getWidth(null);
	} 
	
	/**
	 * Returns the height of the sprite
	 * @return the height of the drawn sprite
	 */
	public int getHeight() {
		return image.getHeight(null);
	}
	
	/**
	 * Draws the sprite on a graphics context at the position x,y
	 * @param g the graphic context to draw on
	 * @param x the x position 
	 * @param y the y position
	 */
	public void draw(Graphics g, int x, int y) {
		g.drawImage(image, x, y, null);
	} 
	
} 
